# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models

# Create your models here.
class Test(models.Model):
    name = models.CharField(max_length=20)

class Contact(models.Model):
    name   = models.CharField(max_length=200)
    age    = models.IntegerField(default=0)
    email  = models.EmailField()

    def __str__(self):
        return "{ \
name:%s, age:%d, email:%s}" % (
self.name, self.age, self.email)

    __repr__ = __str__


class Tag(models.Model):
    contact = models.ForeignKey(Contact, on_delete=models.CASCADE)
    name    = models.CharField(max_length=50)
    def __unicode__(self):
        return self.name


class User(models.Model):
    __tablename__ = 'user'

    uid = models.IntegerField(default=0)
    member_id = models.IntegerField(default=0)
    cs_id = models.IntegerField(default=0)
    nickname = models.CharField(max_length=32)
    avatar = models.CharField(max_length=255)
    pinyin = models.CharField(max_length=50)
    mobile = models.CharField(max_length=32)
    contact_mobile = models.CharField(max_length=32)
    gender = models.IntegerField(default=0)
    birthday = models.IntegerField(default=0)
    id_no = models.CharField(max_length=50)
    parent_mobile = models.CharField(max_length=32)
    mother_mobile = models.CharField(max_length=32)
    founder = models.CharField(max_length=32)
    modifier = models.CharField(max_length=32)
    school_name = models.CharField(max_length=50)
    grade = models.CharField(max_length=32)
    email = models.CharField(max_length=32)
    passport_no = models.CharField(max_length=50)
    pas_valid_time = models.IntegerField(default=0)
    pas_sign_address = models.CharField(max_length=50)
    pas_sign_type = models.IntegerField(default=0)
    pas_front_img = models.CharField(max_length=255)
    pas_back_img = models.CharField(max_length=255)
    ga_no = models.CharField(max_length=50)
    ga_valid_time = models.IntegerField(default=0)
    ga_sign_address = models.CharField(max_length=50)
    ga_sign_type = models.IntegerField(default=0)
    ga_front_img = models.CharField(max_length=255)
    ga_back_img = models.CharField(max_length=255)
    sat_accounts = models.CharField(max_length=32)
    sat_password = models.CharField(max_length=32)
    act_accounts = models.CharField(max_length=32)
    act_password = models.CharField(max_length=32)
    add_time = models.IntegerField(default=0)
    update_time = models.IntegerField(default=0)
    id_front_img = models.CharField(max_length=255)
    id_back_img = models.CharField(max_length=255)

    def __str__(self):
        return "User => { \
uid:%d, member_id:%d, cs_id:%d, nickname:'%s', avatar:'%s',  \
pinyin:'%s', mobile:'%s', contact_mobile:'%s', gender:%d, birthday:%d,  \
id_no:'%s', parent_mobile:'%s', mother_mobile:'%s', founder:'%s', modifier:'%s',  \
school_name:'%s', grade:'%s', email:'%s', passport_no:'%s', pas_valid_time:%d,  \
pas_sign_address:'%s', pas_sign_type:%d, pas_front_img:'%s', pas_back_img:'%s', ga_no:'%s',  \
ga_valid_time:%d, ga_sign_address:'%s', ga_sign_type:%d, ga_front_img:'%s', ga_back_img:'%s',  \
sat_accounts:'%s', sat_password:'%s', act_accounts:'%s', act_password:'%s', add_time:%d,  \
update_time:%d, id_front_img:'%s', id_back_img:'%s'}" % (
self.uid, self.member_id, self.cs_id, self.nickname, self.avatar,
self.pinyin, self.mobile, self.contact_mobile, self.gender, self.birthday,
self.id_no, self.parent_mobile, self.mother_mobile, self.founder, self.modifier,
self.school_name, self.grade, self.email, self.passport_no, self.pas_valid_time,
self.pas_sign_address, self.pas_sign_type, self.pas_front_img, self.pas_back_img, self.ga_no,
self.ga_valid_time, self.ga_sign_address, self.ga_sign_type, self.ga_front_img, self.ga_back_img,
self.sat_accounts, self.sat_password, self.act_accounts, self.act_password, self.add_time,
self.update_time, self.id_front_img, self.id_back_img)

    __repr__ = __str__

